package com.dssingleton;

import java.io.*;

// 单例序列化漏洞测试
public class Main2 {
    public static void main2(String[] args) throws IOException, ClassNotFoundException {
        Dcl instance = Dcl.getInstance();
        System.out.println("instance = " + instance);
//        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("/test_workspace", "dcl.txt")));
//        oos.writeObject(instance);
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("/test_workspace", "dcl.txt")));
        Dcl o1 = (Dcl) ois.readObject();
        System.out.println("o1 = " + o1);
    }

    public static void main(String[] args) throws IOException, ClassNotFoundException {

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("/test_workspace", "dcl.txt")));
        Dcl o1 = (Dcl) ois.readObject();
        System.out.println("o1 = " + o1);

        Dcl instance = Dcl.getInstance();
        System.out.println("instance = " + instance);
    }
}
